package org.stars.dao.sqlmapper;

import java.io.Serializable;
import java.util.Map;
import java.util.Map.Entry;

import org.stars.datastructure.map.CaseInsensitiveHashMap;

/**
 * The Class Parameter.
 *
 * @author Francesco Benincasa
 */
public class Parameter implements Serializable, Cloneable
{
    
    /** The Constant serialVersionUID. */
    private static final long serialVersionUID = -4470137500190150278L;

    /**
     * Instantiates a new parameter.
     */
    public Parameter()
	{
		name		=	"";
		type			=	ParameterType.TYPE_ATTRIBUTE;
		attributes	=	new CaseInsensitiveHashMap<String>();
	}
    
    private Map<String, String> attributes;
	
	/** The type of parameter. */
	private ParameterType type;
	
	/** The attribute. */
	private String name;
	
	private Class<?> typeHandler;
		
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString()
	{
		return name+" ("+type+")";		
	}


	public ParameterType getType() {
		return type;
	}


	public void setType(ParameterType type) {
		this.type = type;
	}


	public String getName() {
		return name;
	}


	public void setName(String attribute) {
		this.name = attribute;
	}


	public Map<String, String> getAttributes() {
		return attributes;
	}


	public void setAttributes(Map<String, String> attributes) {
		this.attributes = attributes;
	}
	
	@Override
	public Parameter clone()
	{
		Parameter newObject=new Parameter();
		
		newObject.name=name;
		newObject.type=type;
		newObject.attributes=new CaseInsensitiveHashMap<String>();
		
		for (Entry<String, String> item: attributes.entrySet())
		{
			newObject.attributes.put(item.getKey(), item.getValue());
		}
		
		return newObject;
	}


	public Class<?> getTypeHandler() {
		return typeHandler;
	}


	public void setTypeHandler(Class<?> typeHandler) {
		this.typeHandler = typeHandler;
	}
	
	
	
	
}


